<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <p>info:{{info}}</p>
        <input type="text" v-model="info">
        <p>msg:{{msg}}</p>
        <input type="button" value="混入方法" @click="showMixin()">
        <hr>
        <comp-a></comp-a>
    </div>
    <div id="root">
        <p>info:{{info}}</p>
        <input type="text" v-model="info">
    </div>
    <template id="child"> 
        <div>
            <p>info:{{info}}</p>
            <input type="text" v-model="info">
            <input type="button" value="混入方法" @click="showMixin()">
        </div>
    </template>
</body>
<script>
    Vue.mixin({
        data(){
            return{
                info:"林志颖"
            }
        },
        methods:{
            showMixin(){
                console.log("mixin混入方法",this);
            }
        },
        mounted(){
            console.log("混入的生命周期钩子函数");
        }
    });
    const mixinOne={
        data(){
            return{
                user:{
                    name:"林志炫"
                }
            }
        }
    };
    const mixinTwo={
        methods:{
            checkMixin(){
                console.log("检测局部混入方法");
            }
        }
    }
    new Vue({
        mixins:[mixinOne],
        el:"#app",
        components:{
            compA:{
                mixins:[mixinOne,mixinTwo],
                template:"#child",
                mounted(){
                    console.log("compA组件");
                }
            }
        },
        data:{
            msg:"林志玲"
        },
        mounted(){
            console.log("new Vue组件");
        }
    });
    new Vue({
        el:"#root"
    })
</script>
</html>